package com.dragon.gateway.config;

import com.dragon.gateway.filter.DragonRequestGlobalFilter;
import com.dragon.gateway.handler.GlobalExceptionHandler;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @date: 2024/8/13 23:13
 * @author: ybl
 */

@Configuration(proxyBeanMethods = false)
public class GatewayConfiguration {

    /**
     * 创建DragonRequest全局过滤器
     * @return DragonRequest全局过滤器
     */
    @Bean
    public DragonRequestGlobalFilter dragonRequestGlobalFilter() {
        return new DragonRequestGlobalFilter();
    }

    /**
     * 创建全局异常处理程序
     * @param objectMapper 对象映射器
     * @return 全局异常处理程序
     */
    @Bean
    public GlobalExceptionHandler globalExceptionHandler(ObjectMapper objectMapper) {
        return new GlobalExceptionHandler(objectMapper);
    }

}
